Skip to content

prettify code blocks for api site #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

kswedberg
Copy link
Member

modified header.php and footer.php in jquery theme to conditionally load prettify.css and prettify.js on api site (for code block syntax highlighting).

@scottgonzalez
Copy link
Member

@rdworth @jzaefferer Can you provide some feedback on how this relates to the work you're currently doing for qunitjs.com? IIRC you were working on doing the processing on the server prior to publishing.

@scottgonzalez
Copy link
Member

Also, it looks like we should clean up our whitespace so that future commits are easy to read :-)

@jzaefferer
Copy link
Member

The qunitjs.com repo is currently using docpad, which we're getting rid of. But the idea is to do the highlighting as part of the deployment, instead of doing it on the client. With gzipped html the overhead should be smaller then highlighting on the client.

@rdworth experimented with pygments, but I don't know how far he got.

@rdworth
Copy link
Contributor

rdworth commented May 29, 2012

I started dissecting how docpad uses pygmentize (command line pygments tool) but didn't get very far. It's basically just stripping that code out (though it's in CoffeeScript) and making a grunt task from it. I'm happy to do it, but might be a couple more days.

@jzaefferer
Copy link
Member

@kswedberg any opinion on server vs client side code highlighting? Might make sense to just go client side for now.

@jzaefferer
Copy link
Member

If we go that route, we need a way for other sites to load this, too: api.jquery.com, api.jqueryui.com, qunitjs.com, probably learn.jquery.com.

@kswedberg
Copy link
Member Author

@jzaefferer Ideally, we should do it on the server. If that's too much of a hassle, though, we could do it client side for now until we have a server-side solution in place.

If multiple other sites need it, too, we can just load the css/js unconditionally. The prettify.js script looks for <pre class="prettyprint"> and <code class="prettyprint"> and syntax-highlights them. If this is a temporary solution, we could hack the script to have it look for a different class name as well.

Everyone, let me know how you'd like me to proceed with this. I can just close this pull request or close it and send another without the conditional loading.

@jzaefferer
Copy link
Member

As we have no solution for server side rendering right now, let's go with client side. Can you update this PR to apply to more then one site?

Does the highlighter have an option to specify the language? Or does it try to auto-detect?

@rdworth
Copy link
Contributor

rdworth commented Jun 1, 2012

I'd like one more day. Gonna focus on this for a good part of today and then if I'm still not there we can go ahead. Thanks for your patience.

@rdworth
Copy link
Contributor

rdworth commented Jun 2, 2012

Ok, I created a pygmentize wrapper https://github.com/rdworth/node-pygmentize . I've got this working on a test file in api.jquery.com ( see pygmentize branch ), but hit a snag on getting the whole repo switched over. Should make some more progress this weekend.

@jzaefferer do you want to try the same on qunitjs.com?

@jzaefferer
Copy link
Member

Implemented node-pygments on qunitjs.com, too, and its here in master, so we can close this PR?

@kswedberg
Copy link
Member Author

Closing this, trusting that pygments is working.

@kswedberg kswedberg closed this Jun 4, 2012
@kswedberg kswedberg deleted the prettifyjs-for-api branch February 11, 2016 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants